package com.zhsm.fuxi.mvp.ui.dialog

import android.content.Context
import com.zhsm.fuxi.R
import com.zhsm.fuxi.base.BaseDialog
import kotlinx.android.synthetic.main.dialog_photo_way_mycenter.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by GuZhC on 2018/10/30.
 * describe:
 */
class ChosePhotoWayDialog(context: Context) : BaseDialog(context) {

    override fun getLayoutId(): Int {
        return R.layout.dialog_photo_way_mycenter
    }

    override fun getGravity(): Int {
        return BaseDialog.GRAVITY_CENTER
    }

    override fun isCanceledOnTouchOutside(): Boolean {
        return true
    }

    override fun initView() {
        super.initView()
        setClick()
        dialogRoot.onClick { dismiss() }
    }


    fun setClick() {
        myCenterDialogTitle.onClick {
            monClickTakePhoto?.takePic()
            dismiss()
        }
        myCenterDialogChosePic.onClick {
            monClickTakePhoto?.chosePic()
            dismiss()
        }
        myCenterDialogCancel.onClick { dismiss() }
    }

    override fun dismiss() {
        super.dismiss()
    }


    interface onClickTakePhoto {
        //拍照
        fun takePic()

        //相册
        fun chosePic()
    }

    private var monClickTakePhoto: onClickTakePhoto? = null

    fun setOnClickTakePhoto(mOnClickTakePhoto: onClickTakePhoto?) {
        this.monClickTakePhoto = mOnClickTakePhoto
    }
}